import glob

from resolver import get_pic_key_points

'''
    func get_video_key_points 传入数据文件夹地址和指定video名称，输出结构化的keyPoints序列，按时间顺序排序
    @params
    path_name:txt数据所在路径名称
    video_name:待处理的video名称
'''
def get_video_key_points(path_name, video_name):
    print('加载文件：{}/{}_*.txt'.format(path_name, video_name))
    path_file_list = glob.glob(pathname='{}/{}_*.txt'.format(path_name, video_name))  # 获取指定视频的关键点列表
    path_file_list.sort(key=lambda x: int(x.split("/")[-1].replace(".txt", "").split("_")[1])) # 排序
    # 如：['./json_results/video3_1.txt', './json_results/video3_2.txt', './json_results/video3_3.txt', ...
    res = []
    for full_file_name in path_file_list:
        file_name = full_file_name.split("/")[-1].replace(".txt", "")
        res.append(get_pic_key_points(full_file_name, file_name, is_full_path=True))
    return res



